﻿using GongSolutions.Wpf.DragDrop;
using KinonekoSoftware.CodariaDB.Documents.Composes;
using KinonekoSoftware.CodariaDB.Documents.Timelines;

namespace KinonekoSoftware.Studio.Pages.Notions
{

    [Associate(View = typeof(PlotsQuickEditorView), ViewModel = typeof(PlotsQuickEditorViewModel))]
    public partial class PlotsQuickEditorView : ForestPage, IDropTarget
    {
        public PlotsQuickEditorView()
        {
            InitializeComponent();
        }

        void IDropTarget.DragOver(IDropInfo dropInfo)
        {
            dropInfo.Effects = DragDropEffects.Move;
        }

        void IDropTarget.Drop(IDropInfo dropInfo)
        {
            var dc   = ViewModel<PlotsQuickEditorViewModel>();
            var data = dropInfo.Data as StoryPoint;

            // if (dc.StoryPointCollection.Contains(data))
            // {
            //     dc.DetachedStoryPointCollection.Add(data);
            //     dc.StoryPointCollection.Remove(data);
            // }
            // else
            // {
            //     dc.StoryPointCollection.Add(data);
            //     dc.DetachedStoryPointCollection.Remove(data);
            // }
        }

        private void OnEnterStoryPoint(object sender, MouseButtonEventArgs e)
        {

            var vm = ViewModel<PlotsQuickEditorViewModel>();
            vm.Layer = (sender as FrameworkElement)?.DataContext as StoryPoint;
            vm.EnterStoryPoint(vm.Layer);
        }
    }
}